package com.gohome.gohomechat.view.activity;

import android.app.Activity;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dllo on 16/2/29.
 */
public class ActivityControl {
    private static final Map<String, Activity> activityMap = new HashMap<>();

    /**
     * 将新创建的activity添加到MMap中
     * @param key
     * @param activity
     */
    public static void addAty(String key,Activity activity){
        activityMap.put(key,activity);
    }
    /**
     * 将销毁的activity从Map中删除
     * @param key
     * @return
     */
    public static boolean removeAty(String key) {
        Activity activity = activityMap.remove(key);
        if (activity == null) {
            return false;
        }
        return true;
    }

    /**
     * 退出程序后,将所有activity删除
     */
    public static void finishAty(){
        for (String s : activityMap.keySet()) {
            activityMap.get(s).finish();
        }

    }
}
